#pragma once

#include <functional>
#include "RTPDecoderHandle.hpp"

#include "StreamSummary.hpp"
#include "RtpPacket.hpp"

#include "RTPDecoderHandle.hpp"
#include "RtpPacket.hpp"

class CodecWrapper;
class StreamHelper {
public:
	StreamHelper(Hi::RTPDecoderHandle& handle, uint32_t width, uint32_t height, void* option, const std::function<void()>& onRequestKeyFrame);
public:
	void ReceivePacket(Hi::RtpPacket* packet);
private:
	bool OnReceivePacketItem(Hi::RtpPacket* packet);
	int ProcessPacket(Hi::RtpPacket* packet, uint16_t lost  = 0);
	void OnHandle();
private:
	StreamSummary summary;

	Hi::RTPDecoderHandle&	  rtpHandle;

	bool outputYuv{false};
	uint32_t scaleWidth{0};
	uint32_t scaleHeight{0};

	std::function<void()> requestKeyFrame;
  
private:
	CodecWrapper* videoDecoder{nullptr};
	void* userOption{nullptr};
	size_t rbgSize{0};
	size_t yuvSize{0};
};